// 依赖
import Vue from 'vue'
import Router from 'vue-router'

// 登录前首页界面
import Index from '@/view/index/index'

// 用户界面
import Account from '@/view/account/index'
import AccountDashboard from '@/view/account/dashboard/index'
import AccountMobile from '@/view/account/mobile/index'
import AccountInvitation from '@/view/account/invitation/index'
import AccountOpenauth from '@/view/account/openauth/index'
import AccountFinal from '@/view/account/final/index'

// 管理界面
import Home from '@/view/home/index'

// i应用
import HomeIapp from '@/view/home/iapp/index'
import HomeIappShop from '@/view/home/iapp/shop/index'
import HomeIappShopList from '@/view/home/iapp/shop/list/index'
import HomeIappShopDetail from '@/view/home/iapp/shop/detail/index'
import HomeIappIorder from '@/view/home/iapp/iorder/index'
import HomeIappIorderDashboard from '@/view/home/iapp/iorder/dashboard/index'

// 概况
import HomeOverview from '@/view/home/overview/index'
import HomeOverviewDashboard from '@/view/home/overview/dashboard/index'
import HomeOverviewMember from '@/view/home/overview/member/index'
import HomeOverviewCoupon from '@/view/home/overview/coupon/index'
import HomeOverviewCouponStatistic from '@/view/home/overview/coupon/statistic'
import HomeOverviewCouponStore from '@/view/home/overview/coupon/store'
import HomeOverviewCouponBatch from '@/view/home/overview/coupon/batch'
import HomeOverviewCouponDetail from '@/view/home/overview/coupon/detail'
import HomeOverviewBonus from '@/view/home/overview/bonus/index'
import HomeOverviewBonusStatistic from '@/view/home/overview/bonus/statistic/index'
import HomeOverviewBonusPlus from '@/view/home/overview/bonus/plus/index'
import HomeOverviewBonusMinus from '@/view/home/overview/bonus/minus/index'
// 客户
import HomeUser from '@/view/home/user/index'
import HomeUserCustomer from '@/view/home/user/customer/index'
import HomeUserCustomerList from '@/view/home/user/customer/list/index'
import HomeUserCustomerDetail from '@/view/home/user/customer/detail/index'
// 会员卡
import HomeUserCard from '@/view/home/user/card/index'
import HomeUserCardList from '@/view/home/user/card/list/index'
import HomeUserCardDetail from '@/view/home/user/card/detail/index'
// 积分
import HomeUserBonus from '@/view/home/user/bonus/index'
import HomeUserBonusRule from '@/view/home/user/bonus/rule/index'
import HomeUserBonusGeneral from '@/view/home/user/bonus/general/index'
import HomeUserBonusCustom from '@/view/home/user/bonus/custom/index'
// 储值
import HomeUserBalance from '@/view/home/user/balance/index'
import HomeUserBalanceList from '@/view/home/user/balance/list/index'
import HomeUserBalanceDetail from '@/view/home/user/balance/detail/index'
// 标签
import HomeUserTags from '@/view/home/user/tags/index'
import HomeUserTagsList from '@/view/home/user/tags/list/index'
import HomeUserTagsDetail from '@/view/home/user/tags/detail/index'
// 营销
import HomeMarketing from '@/view/home/marketing/index'
import HomeMarketingDashboard from '@/view/home/marketing/dashboard/index'
// 抢券、抢红包
import HomeMarketingSnatch from '@/view/home/marketing/snatch/index'
import HomeMarketingSnatchList from '@/view/home/marketing/snatch/list/index'
import HomeMarketingSnatchDetail from '@/view/home/marketing/snatch/detail/index'
// 周期性
import HomeMarketingPeriodicity from '@/view/home/marketing/periodicity/index'
import HomeMarketingPeriodicityList from '@/view/home/marketing/periodicity/list/index'
import HomeMarketingPeriodicityDetail from '@/view/home/marketing/periodicity/detail/index'
// 纪念日
import HomeMarketingMark from '@/view/home/marketing/mark/index'
import HomeMarketingMarkList from '@/view/home/marketing/mark/list/index'
import HomeMarketingMarkDetail from '@/view/home/marketing/mark/detail/index'
// 生日
import HomeMarketingBirthday from '@/view/home/marketing/birthday/index'
import HomeMarketingBirthdayList from '@/view/home/marketing/birthday/list/index'
import HomeMarketingBirthdayDetail from '@/view/home/marketing/birthday/detail/index'
// 唤醒
import HomeMarketingAwaken from '@/view/home/marketing/awaken/index'
import HomeMarketingAwakenList from '@/view/home/marketing/awaken/list/index'
import HomeMarketingAwakenDetail from '@/view/home/marketing/awaken/detail/index'
// 关注
import HomeMarketingSubscribe from '@/view/home/marketing/subscribe/index'
import HomeMarketingSubscribeList from '@/view/home/marketing/subscribe/list/index'
import HomeMarketingSubscribeDetail from '@/view/home/marketing/subscribe/detail/index'
// 进店有礼
import HomeMarketingGiftbag from '@/view/home/marketing/giftbag/index'
import HomeMarketingGiftbagList from '@/view/home/marketing/giftbag/list/index'
import HomeMarketingGiftbagDetail from '@/view/home/marketing/giftbag/detail/index'
// 等位营销
import HomeMarketingQueue from '@/view/home/marketing/queue/index'
import HomeMarketingQueueList from '@/view/home/marketing/queue/list/index'
import HomeMarketingQueueDetail from '@/view/home/marketing/queue/detail/index'
// 限时折扣
import HomeMarketingLimitdiscount from '@/view/home/marketing/limitdiscount/index'
import HomeMarketingLimitdiscountList from '@/view/home/marketing/limitdiscount/list/index'
import HomeMarketingLimitdiscountDetail from '@/view/home/marketing/limitdiscount/detail/index'
// 满减
import HomeMarketingRebate from '@/view/home/marketing/rebate/index'
import HomeMarketingRebateList from '@/view/home/marketing/rebate/list/index'
import HomeMarketingRebateDetail from '@/view/home/marketing/rebate/detail/index'
// 支付有礼
import HomeMarketingPaidpromotion from '@/view/home/marketing/paidpromotion/index'
import HomeMarketingPaidpromotionList from '@/view/home/marketing/paidpromotion/list/index'
import HomeMarketingPaidpromotionDetail from '@/view/home/marketing/paidpromotion/detail/index'
// 裂变
import HomeMarketingFission from '@/view/home/marketing/fission/index'
import HomeMarketingFissionList from '@/view/home/marketing/fission/list/index'
import HomeMarketingFissionDetail from '@/view/home/marketing/fission/detail/index'
// 熟客激励
import HomeMarketingMore from '@/view/home/marketing/more/index'
import HomeMarketingMoreList from '@/view/home/marketing/more/list/index'
import HomeMarketingMoreDetail from '@/view/home/marketing/more/detail/index'
// 优惠券
import HomeMarketingCoupon from '@/view/home/marketing/coupon/index'
import HomeMarketingCouponList from '@/view/home/marketing/coupon/list/index'
import HomeMarketingCouponDetail from '@/view/home/marketing/coupon/detail/index'
// 红包
import HomeMarketingLucky from '@/view/home/marketing/lucky/index'
import HomeMarketingLuckyList from '@/view/home/marketing/lucky/list/index'
import HomeMarketingLuckyDetail from '@/view/home/marketing/lucky/detail/index'
// 商城
import HomeMall from '@/view/home/mall/index'
import HomeMallDashboard from '@/view/home/mall/dashboard/index'
// 公众号
import HomeWeixin from '@/view/home/weixin/index'
import HomeWeixinDashboard from '@/view/home/weixin/dashboard/index'
import HomeWeixinNewsmp from '@/view/home/weixin/newsmp/index'
import HomeWeixinNewspro from '@/view/home/weixin/newspro/index'
import HomeWeixinMenu from '@/view/home/weixin/menu/index'
import HomeWeixinQrlimit from '@/view/home/weixin/qrlimit/index'
import HomeWeixinSendall from '@/view/home/weixin/sendall/index'
// 财务
import HomeFinance from '@/view/home/finance/index'
import HomeFinanceCoupon from '@/view/home/finance/coupon/index'
import HomeFinanceLucky from '@/view/home/finance/lucky/index'
import HomeFinanceBonus from '@/view/home/finance/bonus/index'
import HomeFinanceBalance from '@/view/home/finance/balance/index'
// 设置
import HomeSetting from '@/view/home/setting/index'
import HomeSettingSaas from '@/view/home/setting/saas/index'
import HomeSettingBusiness from '@/view/home/setting/business/index'
import HomeSettingBranch from '@/view/home/setting/branch/index'
import HomeSettingStaff from '@/view/home/setting/staff/index'
import HomeSettingMp from '@/view/home/setting/mp/index'
import HomeSettingWxapp from '@/view/home/setting/wxapp/index'
import HomeSettingWxpay from '@/view/home/setting/wxpay/index'
import HomeSettingAlipay from '@/view/home/setting/alipay/index'
import HomeSettingMass from '@/view/home/setting/mass/index'
import HomeSettingOpen from '@/view/home/setting/open/index'

Vue.use(Router)

const router = new Router({
  routes: [
    // 后台首页, start
    {
      path: '/',
      name: '非码i应用',
      component: Index
    },
    // 后台首页, end
    // 个人中心, start
    {
      path: '/account',
      name: '个人中心',
      component: Account,
      redirect: 'account/dashboard',
      children: [
        // 品牌列表, start
        {
          path: 'dashboard',
          name: '我管理的品牌',
          component: AccountDashboard
        },
        // 品牌列表, end
        // 激活手机号, start
        {
          path: 'mobile',
          name: '账号激活',
          component: AccountMobile
        },
        // 激活手机号, end
        // 邀请码, start
        {
          path: 'invitation',
          name: '验证邀请码',
          component: AccountInvitation
        },
        // 邀请码, end
        // 小程序授权, start
        {
          path: 'openauth',
          name: '授权小程序',
          component: AccountOpenauth
        },
        // 小程序授权, end
        // 商户创建完成, start
        {
          path: 'final',
          name: '创建完成',
          component: AccountFinal
        }
        // 商户创建完成, end
      ]
    },
    // 个人中心, end
    // 商户后台, start
    {
      path: '/home',
      name: '^_^ 非码i应用',
      component: Home,
      redirect: 'home/overview',
      children: [
        {
          path: 'overview',
          name: '概况',
          component: HomeOverview,
          redirect: 'overview/dashboard',
          children: [
            {
              path: 'dashboard',
              name: '控制台',
              component: HomeOverviewDashboard
            },
            {
              path: 'member',
              name: '会员概况',
              component: HomeOverviewMember
            },
            {
              path: 'coupon',
              name: '优惠券概况',
              component: HomeOverviewCoupon,
              redirect: 'coupon/statistic',
              children: [
                {
                  path: 'statistic',
                  name: '总体优惠券数据',
                  component: HomeOverviewCouponStatistic
                },
                {
                  path: 'store',
                  name: '按门店统计',
                  component: HomeOverviewCouponStore
                },
                {
                  path: 'batch',
                  name: '按优惠券批次统计',
                  component: HomeOverviewCouponBatch
                },
                {
                  path: 'detail',
                  name: '优惠券明细',
                  component: HomeOverviewCouponDetail
                }
              ]
            },
            {
              path: 'bonus',
              name: '积分概况',
              component: HomeOverviewBonus,
              redirect: 'bonus/statistic',
              children: [
                {
                  path: 'statistic',
                  name: '总体积分数据',
                  component: HomeOverviewBonusStatistic
                },
                {
                  path: 'plus',
                  name: '送出数据',
                  component: HomeOverviewBonusPlus
                },
                {
                  path: 'minus',
                  name: '消耗数据',
                  component: HomeOverviewBonusMinus
                }
              ]
            }
          ]
        },
        // i应用, start
        {
          path: 'iapp',
          name: 'i应用',
          component: HomeIapp,
          redirect: 'iapp/shop',
          children: [
            // 应用市场, start
            {
              path: 'shop',
              name: '应用市场',
              component: HomeIappShop,
              redirect: 'shop/list',
              children: [
                // 应用列表, start
                {
                  path: 'list',
                  name: '应用列表',
                  component: HomeIappShopList
                },
                // 应用列表, end
                // 应用详情, start
                {
                  path: 'detail',
                  name: '应用详情',
                  component: HomeIappShopDetail
                }
                // 应用详情, end
              ]
            },
            // 应用市场, end
            // i点餐, start
            {
              path: 'iorder',
              name: 'i点餐(茶饮连锁版)',
              component: HomeIappIorder,
              redirect: 'iorder/dashboard',
              children: [
                // i点餐控制台, start
                {
                  path: 'dashboard',
                  name: 'i点餐控制台',
                  component: HomeIappIorderDashboard
                }
                // i点餐控制台, end
              ]
            }
            // i点餐, end
          ]
        },
        // i应用, end
        // 客户
        {
          path: 'user',
          name: '客户',
          component: HomeUser,
          redirect: 'user/customer',
          children: [
            {
              path: 'customer',
              name: '我的会员',
              component: HomeUserCustomer,
              redirect: 'customer/list',
              children: [
                {
                  path: 'list',
                  name: '会员列表',
                  component: HomeUserCustomerList
                },
                {
                  path: 'detail',
                  name: '会员详情',
                  component: HomeUserCustomerDetail
                }
              ]
            },
            {
              path: 'card',
              name: '会员卡',
              component: HomeUserCard,
              redirect: 'card/list',
              children: [
                {
                  path: 'list',
                  name: '会员卡列表',
                  component: HomeUserCardList
                },
                {
                  path: 'detail',
                  name: '会员卡详情',
                  component: HomeUserCardDetail
                }
              ]
            },
            // 积分
            {
              path: 'bonus',
              name: '会员积分',
              component: HomeUserBonus,
              redirect: 'bonus/rule',
              children: [
                {
                  path: 'rule',
                  name: '积分规则',
                  component: HomeUserBonusRule
                },
                {
                  path: 'general',
                  name: '设置通用积分规则',
                  component: HomeUserBonusGeneral
                },
                {
                  path: 'custom',
                  name: '设置自定义积分规则',
                  component: HomeUserBonusCustom
                }
              ]
            },
            {
              path: 'balance',
              name: '会员储值',
              component: HomeUserBalance,
              redirect: 'balance/list',
              children: [
                {
                  path: 'list',
                  name: '储值规则',
                  component: HomeUserBalanceList
                },
                {
                  path: 'detail',
                  name: '储值卡详情',
                  component: HomeUserBalanceDetail
                }
              ]
            },
            {
              path: 'tags',
              name: '会员标签',
              component: HomeUserTags,
              redirect: 'tags/list',
              children: [
                {
                  path: 'list',
                  name: '会员标签列表',
                  component: HomeUserTagsList
                },
                {
                  path: 'detail',
                  name: '会员标签详情',
                  component: HomeUserTagsDetail
                }
              ]
            }
          ]
        },
        // 营销
        {
          path: 'marketing',
          name: '营销',
          component: HomeMarketing,
          redirect: 'marketing/dashboard',
          children: [
            {
              path: 'dashboard',
              name: '营销大全',
              component: HomeMarketingDashboard
            },
            {
              path: 'coupon',
              name: '优惠券',
              component: HomeMarketingCoupon,
              redirect: 'coupon/list',
              children: [
                {
                  path: 'list',
                  name: '优惠券列表',
                  component: HomeMarketingCouponList
                },
                {
                  path: 'detail',
                  name: '编辑优惠券',
                  component: HomeMarketingCouponDetail
                }
              ]
            },
            {
              path: 'lucky',
              name: '红包',
              component: HomeMarketingLucky,
              redirect: 'lucky/list',
              children: [
                {
                  path: 'list',
                  name: '红包列表',
                  component: HomeMarketingLuckyList
                },
                {
                  path: 'detail',
                  name: '编辑红包',
                  component: HomeMarketingLuckyDetail
                }
              ]
            },
            {
              path: 'snatch',
              name: '抢券 / 抢红包',
              component: HomeMarketingSnatch,
              redirect: 'snatch/list',
              children: [
                {
                  path: 'list',
                  name: '抢券 / 抢红包活动列表',
                  component: HomeMarketingSnatchList
                },
                {
                  path: 'detail',
                  name: '编辑抢券活动',
                  component: HomeMarketingSnatchDetail
                }
              ]
            },
            {
              path: 'periodicity',
              name: '周期性营销',
              component: HomeMarketingPeriodicity,
              redirect: 'periodicity/list',
              children: [
                {
                  path: 'list',
                  name: '周期性营销活动列表',
                  component: HomeMarketingPeriodicityList
                },
                {
                  path: 'detail',
                  name: '编辑周期性营销活动',
                  component: HomeMarketingPeriodicityDetail
                }
              ]
            },
            {
              path: 'mark',
              name: '纪念日营销',
              component: HomeMarketingMark,
              redirect: 'mark/list',
              children: [
                {
                  path: 'list',
                  name: '纪念日营销活动列表',
                  component: HomeMarketingMarkList
                },
                {
                  path: 'detail',
                  name: '编辑纪念日营销活动',
                  component: HomeMarketingMarkDetail
                }
              ]
            },
            {
              path: 'birthday',
              name: '生日营销',
              component: HomeMarketingBirthday,
              redirect: 'birthday/list',
              children: [
                {
                  path: 'list',
                  name: '生日营销活动列表',
                  component: HomeMarketingBirthdayList
                },
                {
                  path: 'detail',
                  name: '编辑生日营销活动',
                  component: HomeMarketingBirthdayDetail
                }
              ]
            },
            {
              path: 'awaken',
              name: '沉睡唤醒营销',
              component: HomeMarketingAwaken,
              redirect: 'awaken/list',
              children: [
                {
                  path: 'list',
                  name: '沉睡唤醒营销活动列表',
                  component: HomeMarketingAwakenList
                },
                {
                  path: 'detail',
                  name: '编辑沉睡唤醒营销活动',
                  component: HomeMarketingAwakenDetail
                }
              ]
            },
            {
              path: 'subscribe',
              name: '关注营销',
              component: HomeMarketingSubscribe,
              redirect: 'subscribe/list',
              children: [
                {
                  path: 'list',
                  name: '关注营销活动列表',
                  component: HomeMarketingSubscribeList
                },
                {
                  path: 'detail',
                  name: '编辑关注营销活动',
                  component: HomeMarketingSubscribeDetail
                }
              ]
            },
            {
              path: 'giftbag',
              name: '进店有礼',
              component: HomeMarketingGiftbag,
              redirect: 'giftbag/list',
              children: [
                {
                  path: 'list',
                  name: '进店有礼活动列表',
                  component: HomeMarketingGiftbagList
                },
                {
                  path: 'detail',
                  name: '编辑进店有礼活动',
                  component: HomeMarketingGiftbagDetail
                }
              ]
            },
            {
              path: 'queue',
              name: '等位营销',
              component: HomeMarketingQueue,
              redirect: 'queue/list',
              children: [
                {
                  path: 'list',
                  name: '等位营销活动列表',
                  component: HomeMarketingQueueList
                },
                {
                  path: 'detail',
                  name: '编辑等位营销活动',
                  component: HomeMarketingQueueDetail
                }
              ]
            },
            {
              path: 'limitdiscount',
              name: '限时折扣',
              component: HomeMarketingLimitdiscount,
              redirect: 'limitdiscount/list',
              children: [
                {
                  path: 'list',
                  name: '限时折扣活动列表',
                  component: HomeMarketingLimitdiscountList
                },
                {
                  path: 'detail',
                  name: '编辑限时折扣活动',
                  component: HomeMarketingLimitdiscountDetail
                }
              ]
            },
            {
              path: 'rebate',
              name: '消费满减 / 满折',
              component: HomeMarketingRebate,
              redirect: 'rebate/list',
              children: [
                {
                  path: 'list',
                  name: '消费满减 / 满折活动列表',
                  component: HomeMarketingRebateList
                },
                {
                  path: 'detail',
                  name: '编辑消费满减 / 满折活动',
                  component: HomeMarketingRebateDetail
                }
              ]
            },
            {
              path: 'paidpromotion',
              name: '支付有礼',
              component: HomeMarketingPaidpromotion,
              redirect: 'paidpromotion/list',
              children: [
                {
                  path: 'list',
                  name: '支付有礼活动列表',
                  component: HomeMarketingPaidpromotionList
                },
                {
                  path: 'detail',
                  name: '编辑支付有礼活动',
                  component: HomeMarketingPaidpromotionDetail
                }
              ]
            },
            {
              path: 'fission',
              name: '裂变营销',
              component: HomeMarketingFission,
              redirect: 'fission/list',
              children: [
                {
                  path: 'list',
                  name: '裂变营销活动列表',
                  component: HomeMarketingFissionList
                },
                {
                  path: 'detail',
                  name: '编辑裂变营销活动',
                  component: HomeMarketingFissionDetail
                }
              ]
            },
            {
              path: 'more',
              name: '熟客激励营销',
              component: HomeMarketingMore,
              redirect: 'more/list',
              children: [
                {
                  path: 'list',
                  name: '熟客激励营销活动列表',
                  component: HomeMarketingMoreList
                },
                {
                  path: 'detail',
                  name: '编辑熟客激励营销活动',
                  component: HomeMarketingMoreDetail
                }
              ]
            }
          ]
        },
        {
          path: 'mall',
          name: '商城',
          component: HomeMall,
          redirect: 'mall/dashboard',
          children: [
            {
              path: 'dashboard',
              name: '商城概况',
              component: HomeMallDashboard
            }
          ]
        },
        {
          path: 'weixin',
          name: '公众号',
          component: HomeWeixin,
          redirect: 'weixin/dashboard',
          children: [
            {
              path: 'dashboard',
              name: '公众号概况',
              component: HomeWeixinDashboard
            },
            {
              path: 'newsmp',
              name: '微信图文素材',
              component: HomeWeixinNewsmp
            },
            {
              path: 'newspro',
              name: '高级图文素材',
              component: HomeWeixinNewspro
            },
            {
              path: 'menu',
              name: '自定义菜单',
              component: HomeWeixinMenu
            },
            {
              path: 'qrlimit',
              name: '带参数二维码',
              component: HomeWeixinQrlimit
            },
            {
              path: 'sendall',
              name: '分组群发',
              component: HomeWeixinSendall
            }
          ]
        },
        {
          path: 'finance',
          name: '财务',
          component: HomeFinance,
          redirect: 'finance/coupon',
          children: [
            {
              path: 'coupon',
              name: '优惠券对账',
              component: HomeFinanceCoupon
            },
            {
              path: 'lucky',
              name: '红包对账',
              component: HomeFinanceLucky
            },
            {
              path: 'bonus',
              name: '积分对账',
              component: HomeFinanceBonus
            },
            {
              path: 'balance',
              name: '储值对账',
              component: HomeFinanceBalance
            }
          ]
        },
        {
          path: 'setting',
          name: '设置',
          component: HomeSetting,
          redirect: 'setting/saas',
          children: [
            {
              path: 'saas',
              name: '服务信息',
              component: HomeSettingSaas
            },
            {
              path: 'business',
              name: '品牌信息',
              component: HomeSettingBusiness
            },
            {
              path: 'branch',
              name: '门店管理',
              component: HomeSettingBranch
            },
            {
              path: 'staff',
              name: '员工管理',
              component: HomeSettingStaff
            },
            {
              path: 'mp',
              name: '微信公众号',
              component: HomeSettingMp
            },
            {
              path: 'wxapp',
              name: '微信小程序',
              component: HomeSettingWxapp
            },
            {
              path: 'wxpay',
              name: '微信支付账户',
              component: HomeSettingWxpay
            },
            {
              path: 'alipay',
              name: '支付宝账户',
              component: HomeSettingAlipay
            },
            {
              path: 'mass',
              name: '消息推送',
              component: HomeSettingMass
            },
            {
              path: 'open',
              name: '开放API',
              component: HomeSettingOpen
            }
          ]
        }
      ]
    },
    // 商户后台, end
    // 重定向, start
    {
      path: '*',
      redirect: '/'
    }
    // 重定向, end
  ]
})

// 设置点返回时统一滚动到页面顶部
router.beforeEach((to, from, next) => {
  window.scrollTo(0, 0)
  next()
})

export default router
